﻿using Abp.Domain.Services;
using GN.Pay.Core.Entities;
using GN.Pay.Core.Values;
using GN.Pay.TradeChannel;
using GN.Pay.TradeChannel.Transfers;
using GN.Pay.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Core.Services
{
    /// <summary>
    /// 交易通知服务
    /// </summary>
    public interface ITradeNotifyService : IPayService
    {
        /// <summary>
        /// 签名
        /// </summary>
        /// <param name="notify"></param>
        /// <returns></returns>
        SignDictionary Sign(TradeNotify notify);

        /// <summary>
        /// 付款通知
        /// </summary>
        /// <param name="order">订单</param>
        void PayNotify(ITradeOrderQueryResult order);

        /// <summary>
        /// 付款通知
        /// </summary>
        /// <param name="order">订单</param>
        /// <param name="delay">延迟</param>
        void PayNotify(ITradeOrderQueryResult order, TimeSpan delay);

        /// <summary>
        /// 退款通知
        /// </summary>
        /// <param name="apply">申请</param>
        void RefundNotify(ITradeRefundApplyResult apply);

        /// <summary>
        /// 转账通知
        /// </summary>
        /// <param name="result"></param>
        void TransfersNotify(ITransfersApplyResult result);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="app"></param>
        /// <param name="notifyType"></param>
        /// <param name="appHomeUrl"></param>
        /// <param name="notifyUrl"></param>
        /// <param name="returnUrl"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        TradeNotify PullNotify(AMerchantAppInfo app, int notifyType, string notifyUrl,
            string returnUrl, INotifyData message);

        /// <summary>
        /// 客户端交易通知
        /// </summary>
        /// <param name="notify">通知</param>
        /// <returns></returns>
        Tuple<bool, string> ClientNotify(TradeNotify notify);

        /// <summary>
        /// 更新通知
        /// </summary>
        /// <param name="notify">通知</param>
        TradeNotify UpdateNotify(TradeNotify notify);

        /// <summary>
        /// 扫描项目数量
        /// </summary>
        /// <param name="currentId"></param>
        /// <param name="takeCount"></param>
        /// <returns></returns>
        List<TradeNotify> ScanItems(long currentId, int takeCount);
    }
}
